﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using CoreEx.Common.Linq;
using LinFu.IoC.Configuration;

namespace CoreEx.Database.Linq.Implementation
{
    [Implements(typeof(IExpressionRewriter), ServiceName = "EvaluationRewriter")]
    public class EvaluationRewriter : ExpressionVisitor, IExpressionRewriter
    {
        public Expression Rewrite(Expression expression)
        {
            return Visit(expression);
        }

        protected override Expression VisitLambda(LambdaExpression lambda)
        {
            var e = lambda.Evaluate();
            return base.VisitLambda(e);
        }
    }
}
